﻿using INTEX.DataBase;
using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Events;
using ReflectionStudio.Core.Helpers;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.Windows;
using System.Windows.Data;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for ProductionOrder.xaml
    /// </summary>
    public partial class DSTAB50AV95 : DocumentBase
    {
        #region-------------Properties-----------------------
        public OracleConnection OracleDB;
        public OracleCommand orlReadCommand = new OracleCommand();
        public IntexReptServBLClient proxy;
        private Dictionary<string, object> dicParamater;
        public DataSet dsResult;
        DSTAB50AV95Data m_Data, m_DataX;
        public DataSet dsParamaters;
        DSTAB50AV95Report m_rpt;
        public SETINTEXDB SetData
        {
            get
            {
                return (SETINTEXDB)TryFindResource("SetData");
            }
        }
        #region=====VKPOS=======
        CollectionViewSource vwDSTPLAN
        {
            get
            {
                return (CollectionViewSource)this.TryFindResource("vwDSTPLAN");
            }
        }
        DataRow dwDSTPLAN
        {
            get
            {
                if (vwDSTPLAN.View == null)
                    return null;
                if ((DataRowView)vwDSTPLAN.View.CurrentItem == null)
                    return null;
                return ((DataRowView)vwDSTPLAN.View.CurrentItem).Row;
            }
        }
        #endregion
        string KRS
        {
            get
            {
                return m_Data.Right("  " + txtABPAUFKRS.Text.ToString().Trim(), 2);
            }
        }
        string LFD
        {
            get
            {
                return m_Data.Right("000000" + txtABPAUFLFD.Text.ToString().Trim(), 6); ;
            }
        }
        #endregion
        public DSTAB50AV95()
        {
            InitializeComponent();
            this.Name = "生产进展";

        }
        public override void SetUp(Dictionary<string, object> dicParamater)
        {
            dicParamater["blBuildCellMastrix"] = false;
            base.SetUp(dicParamater);
            InitializeComponent();
            this.dicParamater = dicParamater;
            OracleDB = (OracleConnection)dicParamater["OracleDB"];
            dsParamaters = (DataSet)dicParamater["dsParamaters"];
            proxy = (IntexReptServBLClient)dicParamater["proxy"];
            m_Data = new DSTAB50AV95Data(OracleDB, proxy);
            //txtABPAUFKRS.Text = "FB";
            //txtABPAUFLFD.Text = "002390";
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {


            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return;

        }
        private void btnQuery_Click(object sender, EventArgs e)
        {
            try
            {
                return;
                DataSet Result = new DataSet();
                DataRow dwABPOS = null;
                Result = m_Data.BuildData(dwABPOS); 
                SetData.Clear();
                SetData.Merge(Result);
                txtTotal.Text = Result.Tables[0].Rows.Count.ToString();
                /*
                vwDSTPLAN.Source = SetData.Tables["DSTPLAN_AB50"];
                if (vwDSTPLAN != null)
                {
                    if (vwDSTPLAN.View != null)
                    {
                        vwDSTPLAN.View.MoveCurrentToFirst();
                    }
                }*/
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        private void btnPrint_Click(object sender, EventArgs e)
        {

            using (new LongOperation(this, "刷新中"))
            {
                DataSet setRpt = new DataSet();

                if (setRpt == null)
                    return;
                m_DataX = new DSTAB50AV95Data(dicParamater);
                m_DataX.OracleDB = this.OracleDB;
                m_DataX.proxy = this.proxy;
                if (m_DataX.exAgent._app == null)
                {
                    m_DataX.exAgent = new ExcelX.ExcelLib.ExcelAgent(dicParamater);
                }
                m_rpt = new DSTAB50AV95Report(dicParamater);
                DataSet Result = new DataSet();
                DataRow dwABPOS = null;
                Result = m_Data.BuildData(dwABPOS);
                m_rpt.dsSource = Result;
                m_rpt.exAgent = m_DataX.exAgent;
                m_rpt.WriteExcelReport("EXCEL");
            }
        } 
    }
}
